<?php
$sub_menu = "230150";
include_once("./_common.php");

check_demo();

auth_check($auth[$sub_menu], "w");

check_token();

if ($w == "")
{
    if (!trim($gd_name))
        alert("등급 이름이 없습니다.");

    $sql = "insert into {$mw_cash['grade_table']} ";
    $sql.= "   set gd_name = '{$gd_name}' ";
    $sql.= "     , gd_use = '{$gd_use}' ";
    $sql.= "     , gd_cash = '{$gd_cash}' ";
    $sql.= "     , gd_period = '{$gd_period}' ";
    $sql.= "     , gd_point_save = '{$gd_point_save}' ";
    sql_query($sql);

    $gd_id = mysql_insert_id();
}
else if ($w == "u")
{
    if (!trim($gd_name))
        alert("등급 이름이 없습니다.");

    if (!trim($gd_id))
        alert("gd_id 가 없습니다.");
 
    $sql = "update {$mw_cash['grade_table']} ";
    $sql.= "   set gd_name = '{$gd_name}' ";
    $sql.= "     , gd_use = '{$gd_use}' ";
    $sql.= "     , gd_cash = '{$gd_cash}' ";
    $sql.= "     , gd_period = '{$gd_period}' ";
    $sql.= "     , gd_point_save = '{$gd_point_save}' ";
    $sql.= " where gd_id = '{$gd_id}' ";
    sql_query($sql);
}
else if ($w == "d")
{
    if (!trim($gd_id))
        alert("gd_id 가 없습니다.");

    sql_query("delete from {$mw_cash['grade_table']} where gd_id = '{$gd_id}'");

    alert("삭제했습니다.", "mw.grade.php");
}

goto_url("mw.grade.form.php?gd_id={$gd_id}&w=u");

